﻿using System;
using System.IO;
using System.Globalization;

namespace LAPI.Core.Helpers
{
    public class TextHelper
    {
        public static string Nvl(string cad, string defaultValue)
        {
            return (cad == null) ? defaultValue : cad;
        }

        public static string Nvl(string cad)
        {
            return (cad == null) ? string.Empty : cad;
        }

        public static string CadenaVacia(string cad, string defaultValue)
        {
            return (string.IsNullOrEmpty(cad)) ? defaultValue : cad;
        }

        public static string QuitaAcentos(string palabra)
        {
            return palabra.Replace("á", "a")
                          .Replace("é", "e")
                          .Replace("í", "i")
                          .Replace("ó", "o")
                          .Replace("ú", "u")
                          .Replace("ñ", "n")
                          .Replace("Á", "A")
                          .Replace("É", "E")
                          .Replace("Í", "I")
                          .Replace("Ó", "O")
                          .Replace("Ú", "U")
                          .Replace("Ñ", "N")
                          ;
        }


        /*public static string _QuitaAcentos(string palabra)
        {
            string aMin   = "á";
            string eMin   = "é";
            string iMin   = "í";
            string oMin   = "ó";
            string uMin   = "ú";
            string eneMin = "ñ";

            string aMay = "Á";
            string eMay = "É";
            string iMay = "Í";
            string oMay = "Ó";
            string uMay = "Ú";
            string eneMay = "Ñ";

            string texto = palabra;

            for (int i = 0; i < palabra.Length; i++)
            {
                string x = palabra.Substring(i, 1);

                if (x == aMin)        texto = texto.Replace(x, "a");
                else if (x == aMay)   texto = texto.Replace(x, "A");
                else if (x == eMin)   texto = texto.Replace(x, "e");
                else if (x == eMay)   texto = texto.Replace(x, "E");
                else if (x == iMin)   texto = texto.Replace(x, "i");
                else if (x == iMay)   texto = texto.Replace(x, "I");
                else if (x == oMin)   texto = texto.Replace(x, "o");
                else if (x == oMay)   texto = texto.Replace(x, "O");
                else if (x == uMin)   texto = texto.Replace(x, "u");
                else if (x == uMay)   texto = texto.Replace(x, "U");
                else if (x == eneMin) texto = texto.Replace(x, "n");
                else if (x == eneMay) texto = texto.Replace(x, "N");
            }

            return texto;
        }*/
    }
}